package com.zatech.cgnci.project.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zatech.cgnci.project.dto.CgnciRateDTO;
import com.zatech.cgnci.project.dto.RateQueryDTO;
import com.zatech.cgnci.project.service.CgnciRateService;
import com.zatech.cgnci.project.vo.RateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 汇率信息表 前端控制器
 * </p>
 *
 * @author Generator
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/api/rate")
@RequiredArgsConstructor
@Api(tags = "汇率录入接口")
public class CgnciRateController {
   
    private final CgnciRateService cgnciRateService;

    @PostMapping("/page")
    @ApiOperation("分页查询汇率")
    public IPage<RateVO> page(@RequestBody RateQueryDTO queryDTO) {
        return cgnciRateService.pageRate(queryDTO);
    }

    @PostMapping("/insert")
    @ApiOperation("新增汇率")
    public void insertRate(@RequestBody @Valid CgnciRateDTO cgnciRateDTO) {
        cgnciRateService.insertRate(cgnciRateDTO);
    }
    
    @PostMapping("/update")
    @ApiOperation("修改汇率")
    public void updateRate(@RequestBody @Valid CgnciRateDTO cgnciRateDTO) {
        cgnciRateService.updateRate(cgnciRateDTO);
    }
    
    @PostMapping("/delete")
    @ApiOperation("删除汇率")
    public void deleteRate(@RequestParam(value = "rateId") Long rateId) {
        cgnciRateService.removeById(rateId);
    }

}

